﻿#horse jumping

:const delay_sec 12

:alias mode v1
:alias fX v2
:alias fY v3
:alias hY v4
:alias hX v5
:alias scoreX v5
:alias scoreY v6
:alias score v7

: main
	fX := 63
	fY := 10
	hY := 10
	hX := 15
	score := 0
	scoreX := 5
	scoreY := 2

	loop
		clear

		i  := hex score
		sprite scoreX scoreY 5

		if fX == 63 then vf := 0

		#draw fences
		fX += -4
		i := fenceLarge
		sprite fX fY 0
		
		i := horse1		
		if mode == 1 then i := horse2
		mode += 1
		if mode == 2 then mode := 0		
		
		if mode < 2 begin
			v0 := 0
			if v0 key then mode := 3
		end

		if mode == 3 begin
			i := horseup
			hY := 7
		end
		if mode == 4 begin
			i := horseup
			hY := 4
		end
		if mode == 5 begin
			i := horseover
		end
		if mode == 6 begin
			i := horseover
		end
		if mode == 7 begin
			i := horsedown
			hY := 7
		end
		if mode == 8 begin
			i := horsedown
			hY := 10
		end

		sprite hX hY 0

		if mode == 8 then mode := 1

		if fX == 3 begin
			fX := 63
			if vf == 1 begin
				score := 0
			else
				score += 1
			end
		end

		# lock the framerate of this program via the delay timer:
		loop
			vf := delay
			if vf != 0 then
		again
		vf := delay_sec
		delay := vf
	again


# Sprites
: horse1
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x08 0x00 0x1C 0x00 0x3A 
0x00 0x70 0x1F 0xE0 0x2F 0xE0 0x4F 0xE0 
0x0C 0x70 0x18 0x08 0x20 0x04 0x00 0x00 

: horse2
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x1E 
0x00 0x7D 0x3F 0xF8 0x4F 0xF0 0x0F 0xE0 
0x1C 0x60 0x08 0x40 0x04 0x80 0x00 0x00 

: horseup
0x00 0x08 0x00 0x3C 0x00 0x7A 0x18 0xF0 
0x27 0xF8 0x0F 0xE4 0x1F 0x88 0x0C 0x00 
0x08 0x00 0x10 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 

: horseover
0x00 0x04 0x00 0x1E 0x00 0x3D 0x60 0xF8 
0xFF 0xF0 0x3F 0xE0 0x7F 0xF0 0x4F 0x88 
0x80 0x10 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 

: horsedown
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x60 0x10 0x18 0x38 0x0E 0x74 
0x1F 0xF0 0x2F 0xF0 0x23 0xF0 0x00 0x18 
0x00 0x04 0x00 0x02 0x00 0x00 0x00 0x00 



: fenceLarge
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x24 0x00 0x3C 0x00 0x24 
0x00 0x3C 0x00 0x24 0x00 0x3C 0x00 0x24 
0x00 0x3C 0x00 0x3C 0x00 0x7C 0x00 0x1E 